Configure Local Yum Repository Server
2017/04/11 |
Configure Local Yum Repository Server to update packages faster for local Servers.
On this example, Configure [base], [updates], [extras] mirror repositories that are enabled by default settings on CentOS.
|
|
[1] | |
[2] | Install other required packages. |
[root@dlp ~]# yum -y install rsync createrepo
|
[3] | Create directories for repository and copy data from CentOS official Repository. |
# create directories [root@dlp ~]# mkdir -p /var/www/repos/centos/7/{os,updates,extras}/x86_64 [root@dlp ~]# chmod -R 755 /var/www/repos
# copy from official repo [root@dlp ~]# rsync -avz --delete --exclude='repodata' \
rsync://ftp.riken.jp/centos/7/os/x86_64/ \ /var/www/repos/centos/7/os/x86_64/
[root@dlp ~]#
rsync -avz --delete --exclude='repodata' \
rsync://ftp.riken.jp/centos/7/updates/x86_64/ \ /var/www/repos/centos/7/updates/x86_64/
[root@dlp ~]#
rsync -avz --delete --exclude='repodata' \
rsync://ftp.riken.jp/centos/7/extras/x86_64/ \ /var/www/repos/centos/7/extras/x86_64/ # create metadata repositories [root@dlp ~]# createrepo /var/www/repos/centos/7/os/x86_64/ [root@dlp ~]# createrepo /var/www/repos/centos/7/updates/x86_64/ [root@dlp ~]# createrepo /var/www/repos/centos/7/extras/x86_64/ |
[4] | Add copy task to daily jobs. |
[root@dlp ~]#
vi /etc/cron.daily/update-repo # create new #!/bin/bash VER='7' ARCH='x86_64' REPOS=(os updates extras) for REPO in ${REPOS[@]} do rsync -avz --delete --exclude='repodata' \ rsync://ftp.riken.jp/centos/${VER}/${REPO}/${ARCH}/ /var/www/repos/centos/${VER}/${REPO}/${ARCH}/ createrepo /var/www/repos/centos/${VER}/${REPO}/${ARCH}/ done chmod 755 /etc/cron.daily/update-repo |
[5] | Configure Apache httpd to provide repository for other Client Servers. |
[root@dlp ~]#
vi /etc/httpd/conf.d/repos.conf # create new Alias /repos /var/www/repos <directory /var/www/repos> Options +Indexes Require all granted </directory> systemctl restart httpd |
[6] | If Firewalld is running, allow HTTP service. |
[root@dlp ~]# firewall-cmd --add-service=http --permanent success [root@dlp ~]# firewall-cmd --reload success |
[7] | On Client Servers, Change settings of Yum to refer to Local Yum Mirror. It's OK all. |
[root@client ~]#
vi /etc/yum.repos.d/CentOS-Base.repo [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=http://dlp.srv.world/repos/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra baseurl=http://dlp.srv.world/repos/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra baseurl=http://dlp.srv.world/repos/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 |